def reverse(l):
    c = l.head
    p = None
    n = None
    while c is not None:
        n = c.next
        c.next = p
        p = c
        c = n
    l.head = p
    return l